package com.bana.fvs.app.mvp.presenter;

import android.app.Activity;
import android.util.Log;

import com.bana.fvs.app.enter.NewVersionBean;
import com.bana.fvs.app.mvp.contract.NewVersionContract;
import com.bana.fvs.app.mvp.model.NewVersionModel;
import com.wei.commonlibrary.net.CommException;
import com.wei.commonlibrary.net.MyDefaultCallback;

/**
 * Author : yanftch
 * Date : 2018/3/1
 * Time : 21:51
 * Desc :
 */

public class NewVersionPresenter extends NewVersionContract.AbsNewVersionPresenter {
    private static final String TAG = "dah_NewVersionPresenter";
    @Override
    public void http_getNewVersion(Activity activity, String token, String versionName) {
        mModel.http_getNewVersion(token, versionName).callback(new MyDefaultCallback<NewVersionBean>(activity, false) {
            @Override
            public void onError(CommException e) {
                Log.e(TAG, "onError: =====-----"+e.getMessage());
                if (getView() != null) {
                    getView().onError(e);
                }
            }

            @Override
            public void response(NewVersionBean versionBean) {
                Log.e(TAG, "response: versionBean===----"+versionBean+"       getView()---"+getView());
                if (getView() != null) {
                    getView().onResponse(versionBean);
                }
            }
        });
    }

    @Override
    protected NewVersionContract.AbsNewVersionModel createModel() {
        return new NewVersionModel();
    }
}
